package client;

import java.util.Deque;

import lib.Commands;

public class ConsoleClient extends Thread implements Client {

	String host = "localhost";
	private int PORT = 11011;
	TCPClientListener listener;

	public ConsoleClient(String host) throws Exception {
		this.host = host;
		listener = new TCPClientListener(this, host, PORT);
		listener.start();
		this.start();
	}

	public void run() {
		while (true) {
			send(System.console().readLine());
		}
	}

	public void displayMessage(String msg) {
		System.out.println(msg);

	}

	public void send(String msg) {
		listener.send(msg);
	}

	public void send(Commands cmd, String msg) {
		listener.send(cmd + " " + msg);
	}

	public void exit() {

	}


	public void displayInfo(Deque<String> msg) {
		displayMessage(listener.getMessage(msg));		
	}



	
	public void progress(String msg, int progress) {
		// TODO Auto-generated method stub
		
	}

	public void list(Deque<String> msg) {
		displayMessage( listener.getMessage(msg));
		
	}

}
